fix: scale raw ADC values in CSV and JSON SD card parsers#152
fix: scale raw ADC values in CSV and JSON SD card parsers#152
Conversation
The firmware writes raw ADC integer counts (not voltages) to CSV and JSON log files. The CSV parser was passing these through as-is, causing values like 22 ADC counts to display as 22V instead of ~0.003V. Changes: - Add ScaleRawAnalogValues to both CSV and JSON parsers, matching the protobuf parser's formula: (raw/resolution * portRange * calM + calB) * scaleM - Parse CSV column headers to distinguish ain* (analog) from dio* (digital) columns — previously the dio pair was treated as analog - Add tests for scaling with/without calibration config and DIO handling Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: a0fb8798807b
Review Summary by QodoScale raw ADC values in CSV and JSON SD card parsers
WalkthroughsDescription• Scale raw ADC values in CSV and JSON parsers using calibration formula • Parse CSV column headers to distinguish analog (ain*) from digital (dio*) columns • Add comprehensive tests for ADC scaling with/without calibration config • Fix digital data handling in CSV parser (previously treated as analog) Diagramflowchart LR
Raw["Raw ADC Values<br/>from CSV/JSON"]
Parse["Parse Column Layout<br/>ain* vs dio*"]
Scale["Scale Formula<br/>raw/resolution * range * calM + calB * scaleM"]
Output["Scaled Voltage Values<br/>+ Digital Data"]
Raw --> Parse
Parse --> Scale
Scale --> Output
File Changes1. src/Daqifi.Core.Tests/Device/SdCard/SdCardCsvFileParserTests.cs
|
Code Review by Qodo
1.
|
Use the dio timestamp as the row timestamp when no analog channels are present, instead of returning null and silently dropping the row. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: a0fb8798807b
The firmware writes raw ADC integer counts (not voltages) to CSV and JSON log files. The CSV parser was passing these through as-is, causing values like 22 ADC counts to display as 22V instead of ~0.003V.
Changes: